﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace T12OOP
{
    class Program
    {
        static void Main(string[] args)
        {
            #region 类与构造函数
            Account acc1 = new Account();
            Console.WriteLine( acc1 );
            Account acc2 = new Account("zhangsan",1000);
            Console.WriteLine(acc2);
            #endregion 
            #region 单例模式
            SingleTon s1 = SingleTon.GetInstance();
            SingleTon s2 = SingleTon.GetInstance();
            if (s1==s2)
            {
                Console.WriteLine("SingleTon类的两个实例s1与s2是相同的！");
            }
            #endregion
            #region 属性
            Student stu = new Student();
            stu.Name = "zhangsan";
            //异常处理：友好的对待有可能出现的错误
            try {
                stu.Age = 21;
                stu.Age = -21;
            }
           catch(Exception)
            {
                Console.WriteLine("年龄不能超出指定范围");
            }
            //stu.Age = 21;
            //stu.Age = -21;
            Console.WriteLine(stu);
            #endregion
            #region 索引属性
            Contact c = new Contact("zhangsan");
            //c.Name="只读属性不能赋值"；
            Console.WriteLine(c.Name);
            c["mobile"] = "12345";
            c["home"] = "12345";
            c["business"] = "12345";
            c["fax"] = "12345";
            Console.WriteLine(c);
            #region 预定义操作符重载
            GameValue gv1 = new GameValue();
            gv1.Hp = 10;
            gv1.Mp = 20;
            gv1.Sp = 30;
            GameValue gv2 = new GameValue();
            gv2.Hp = 10;
            gv2.Mp = 20;
            gv2.Sp = 30;
            Console.WriteLine(gv1+gv2);

            #endregion



            #endregion
            Console.ReadKey();
        }
    }
}
